<template>
  <div>
      <el-checkbox-group v-model="checkList" v-for="i in datas" :key="i.id">
        <el-checkbox :label="i.id">{{i.name}}</el-checkbox>
        
    </el-checkbox-group>
    <el-button @click="add">添加权限</el-button>
    
  </div>
</template>

<script>
import axios from 'axios'
export default {
    name:"permission",
    data(){
        return{
            datas:[],
            checkList:[],
            userid : localStorage.getItem('uid')
            
        }
    },
    methods:{
        getpermission(){
            axios.get('/resourcelist').then(res=>{
            console.log(res);
            this.datas = res.data.list
        })
        },
        add(){
            axios.post('/resourcelist',{'userid':this.userid,'reslist':this.checkList}).then(res=>{
                console.log(res);
            })
        },
        getuser_res(){
            axios.get('/user_res?user_id='+this.userid).then(res=>{
            console.log(res);
            this.checkList = res.data.list
        })
        },

    },
    mounted(){
        this.getpermission()
        this.getuser_res()
    }
}
</script>

<style>

</style>